package com.oss.model;

import java.io.Serializable;
import java.util.Date;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/**
 * @author xueqiang.mi
 * @since 2010-8-2
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Topic implements Serializable {
	private static final long serialVersionUID = -8876388749529073810L;

	@PrimaryKey
	private String id;
	@Persistent
	private String name;
	@Persistent
	private String author;
	@Persistent
	private Date createdDate = new Date();
	@Persistent
	private Boolean enabled = true;
	@Persistent
	private Long linkQuantity = 0L;

	public Topic() {
	}

	public Topic(String name) {
		this.name = name;
	}

	public void add1Link() {
		linkQuantity++;
	}

	public String getAuthor() {
		return author;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public String getId() {
		return id;
	}

	public Long getLinkQuantity() {
		return linkQuantity;
	}

	public String getName() {
		return name;
	}

	public boolean isNew() {
		return (this.id == null);
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setLinkQuantity(Long linkQuantity) {
		this.linkQuantity = linkQuantity;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "Topic [id=" + id + ", name=" + name + "]";
	}

}
